{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0;
        margin-top: 0
    }

    #title span {
        float: right;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <!--<a class="btn btn-default btn-outline {present name='channel'}{else /}asdlkjasd{/present}"
                           href="{:url('words')}{/present}{present name='status'}/status/{$status}{/present}">全部</a>-->
                        <a class="btn btn-default btn-outline {eq name='channel' value='2'}asdlkjasd{/eq}"
                           href="{:url('greetWords',['channel'=>'2'])}{present name='status'}/status/{$status}{/present}">文字</a>
                        <a class="btn btn-default btn-outline {eq name='channel' value='1'}asdlkjasd{/eq}"
                           href="{:url('greetWords',['channel'=>'1'])}{present name='status'}/status/{$status}{/present}">语音</a>
                        <a class="btn btn-default btn-outline {eq name='channel' value='3'}asdlkjasd{/eq}"
                           href="{:url('greetWords',['channel'=>'3'])}{present name='status'}/status/{$status}{/present}">图片</a>
                    </div>
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {eq name='status' value='0'}asdlkjasd{/eq}"
                           href="{:url('greetWords',['status'=>'0'])}{present name='channel'}/channel/{$channel}{/present}">审核</a>
                        <a class="btn btn-default btn-outline {eq name='status' value='1'}asdlkjasd{/eq}"
                           href="{:url('greetWords',['status'=>'1'])}{present name='channel'}/channel/{$channel}{/present}">通过</a>
                        <a class="btn btn-default btn-outline {eq name='status' value='-1'}asdlkjasd{/eq}"
                           href="{:url('greetWords',['status'=>'-1'])}{present name='channel'}/channel/{$channel}{/present}">拒绝</a>
                    </div>
                    <div class="fixed-table-toolbar">
                        <form  method="get" action="">
                            <div class="pull-left search">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="search">
                                        <option value="user_id" {php}if(input('?param.search')){if(input('param.search')=='user_id'){echo "selected";} }{/php}>用户ID</option>
                                        <option value="content" {php}if(input('?param.search')){if(input('param.search')=='content'){echo "selected";} }{/php}>内容</option>
                                    </select>
                                </div>
                                {php}
                                if(input('?param.name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('greetWords')}">返回列表</a>
                                </div>{php}
                                }
                                {/php}
                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
                                           {php}
                                           if(input('?param.name')){
                                    if(input('param.name')){
                                    echo "value='".input('name')."'";
                                    }

                                    }
                                    {/php}
                                    name="name" placeholder="搜索">
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                            <table data-toggle="table">
                                <thead>
                                <tr>
                                    <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">类型</th>
                                    <th data-align="center">用户ID</th>
                                    <th data-align="center">内容</th>
                                    <th data-align="center">创建时间</th>
                                    <th data-align="center">更新时间</th>
                                    

                                    <th data-align="center">审核时间</th>
                                    <th data-align="center">审核人</th>


                                    <th data-align="center">管理</th>
                                </tr>
                                </thead>
                                <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                                    <td>{$v.id}</td>
                                    <td>
                                        {if condition="$v.channel==1"}
                                        <span class="btn btn-primary btn-xs" style="background-color:#D8BFD8;border-color:#D8BFD8">语音</span>
                                        {elseif condition="$v.channel==2"}
                                        <span class="btn btn-primary btn-xs" style="background-color:#ADD8E6;border-color:#ADD8E6">文字</span>
                                        {/if}
                                    </td>
                                    {php}
                                    $userinfo = _user_cache($v['user_id']);
                                    $entertainment = ['娱乐','经验','交友','相亲'];
                                    {/php}
                                    <td>{$v.user_id}
                                        {if condition="$userinfo"}
                                        <br /> {$userinfo['name']} <span style="color: seagreen;">[{$entertainment[$userinfo['entertainment']]}]</span></td>
                                        {/if}
                                    <td>

                                        {if condition="$v.channel==1"}
                                        <audio src="__ROOT__{$v.content}" controls="controls">Your browser does not support the audio element.</audio>
                                        {elseif condition="$v.channel==3"}
                                        <img onclick="lookBigImg('__ROOT__{$v.content}')" width="100" height="100" src="__ROOT__{$v.content}" />
                                        {elseif condition="$v.channel==2"}
                                        {$v.content}
                                        {/if}
                                    </td>
                                    <td> 
                                        <span {php}if(date('Y-m-d')==date('Y-m-d', $v['create_time']))echo 'style="color: #ed5565"';{/php}>
                                            {:date('Y-m-d H:i', $v.create_time)}
                                        </span>
                                    </td>
                                    <td> 
                                        <span {php}if(date('Y-m-d')==date('Y-m-d', $v['update_time']))echo 'style="color: #ed5565"';{/php}>
                                            {neq name="$v.update_time" value="0"}{:date('Y-m-d H:i', $v.update_time)}{/neq}
                                        </span>
                                    </td>
                                    <td>
                                        <span>{neq name="$v.shenhe_time" value="0"}{:date('Y-m-d H:i:s', $v.shenhe_time)}{/neq}</span>
                                    </td>
                                    <td>
                                        <span>{:_getAdminName($v.shenhe_admin_id)}</span>
                                    </td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                <!--<li><a onClick="add('{:url('addWords',['id'=>$v['id'], 'url' => -1])}')">修改</a></li>
                                                <li class="divider"></li>-->
                                                {switch name="$v.status"}
                                                {case value="0"}
                                                <li><a onClick="shenhe({$v.id},'1')"><span style="color: #1ab394; ">通过</span></a></li>
                                                <li class="divider"></li>
                                                <li><a onClick="shenhe({$v.id},'-1')"><span style="color: #ed5565; ">拒绝</span></a></li>
                                                {/case}
                                                {/switch}
                                                <li class="divider"></li>
                                                <li><a onClick="del({$v.id})">删除</a></li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-6">
                    <div  class="btn btn-outline btn-default" onclick="alla(1)">
                        批量通过
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla(-1)">
                        批量拒绝
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla(0)">
                        批量审核
                    </div>
                    <a href="?order=1" type="button" class="btn btn-outline btn-default">
                        倒序排序
                    </a>
                    <a href="?order=2" type="button" class="btn btn-outline btn-default">
                        顺序排序
                    </a>
                    <div  class="btn btn-outline btn-default" onclick="alla('del')">
                        批量删除
                    </div>
                </div>
                <div class="col-sm-6 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script type="text/javascript">

    $(document).ready(function(){
        $('#delidAll').click(function(){
            $('input[type=checkbox]').each(function(){
                var self=$(this);
                if(!self.prop('checked')){
                    self.prop('checked',true);
                }else{
                    self.prop('checked',false);
                }
            });
        })
    });

    function del(id){
        swal_del(id,"{:url('delGreetWords')}")
    }

    function member(id)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("member/index")}?search=id&name='+id
            });
        });
    }

    function shenhe(id,value){
        ajaxFun("post","{:url('checkGreetWords')}",{id:id,status:value},'json',function(ret){
            if(ret){
                if(ret.ret){
                    layer.msg(ret.ret)
                    window.location.reload()
                }else{
                    layer.msg(ret.err)
                }
            }else{
                swal_msg("错误",ret,"error");
            }
        })
    }
function alla(types){
    var all=$(".form-horizontal").serialize();
    var alls=$(".form-horizontal").serializeArray();
    console.log(JSON.stringify(alls))

    ajaxFun("post",'{:url('chat/checkGreetWordsAll')}?type='+types,all,'json',function(ret){
        if(ret){
            swal_msg('操作成功','','success',1)
        }
    })

}

</script>
